<template>
  <div class="weather">
    <!-- 云朵元素 -->
    <div class="cloud-1"></div>
    <div class="cloud-2"></div>
    <div class="cloud-3"></div>
    <div class="cloud-4"></div>
    <div class="cloud-5"></div>
    
    <Header class="header-animate" />
    <transition name="fade-view" mode="out-in">
      <router-view />
    </transition>
  </div>
</template>

<script setup>
import Header from './components/Header.vue'
</script>

<style lang="scss">
* {
  margin: 0;
  box-sizing: border-box;
}

.weather {
  /* 动态渐变背景 */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-size: 200% 200%;
  animation: bgMove 15s ease-in-out infinite alternate;
  flex-direction: column;
  min-height: 100vh;
  display: flex;
  color: white;
  position: relative;
  overflow: hidden;
  
  // 天气背景动画
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
      radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
      radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
      radial-gradient(circle at 40% 80%, rgba(120, 119, 198, 0.2) 0%, transparent 50%);
    animation: weatherBg 20s ease-in-out infinite;
    z-index: 0;
  }
  
  // 主云朵效果
  &::after {
    content: '';
    position: absolute;
    top: 5%;
    left: -150px;
    width: 200px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    animation: cloudMove 18s linear infinite;
    z-index: 1;
    
    // 添加云朵的圆形部分
    &::before {
      content: '';
      position: absolute;
      top: -25px;
      left: 35px;
      width: 55px;
      height: 55px;
      background: rgba(255, 255, 255, 0.1);
      border-radius: 50%;
    }
    
    &::after {
      content: '';
      position: absolute;
      top: -20px;
      right: 30px;
      width: 50px;
      height: 50px;
      background: rgba(255, 255, 255, 0.1);
      border-radius: 50%;
    }
  }
  
  // 云朵1
  .cloud-1 {
    position: absolute;
    top: 12%;
    left: -180px;
    width: 140px;
    height: 45px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    animation: cloudMove 14s linear infinite;
    z-index: 1;
    
    &::before {
      content: '';
      position: absolute;
      top: -18px;
      left: 25px;
      width: 45px;
      height: 45px;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 50%;
    }
    
    &::after {
      content: '';
      position: absolute;
      top: -12px;
      right: 20px;
      width: 40px;
      height: 40px;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 50%;
    }
  }
  
  // 云朵2
  .cloud-2 {
    position: absolute;
    top: 22%;
    left: -220px;
    width: 160px;
    height: 55px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 27px;
    animation: cloudMove 22s linear infinite;
    z-index: 1;
    
    &::before {
      content: '';
      position: absolute;
      top: -22px;
      left: 30px;
      width: 55px;
      height: 55px;
      background: rgba(255, 255, 255, 0.06);
      border-radius: 50%;
    }
    
    &::after {
      content: '';
      position: absolute;
      top: -18px;
      right: 25px;
      width: 50px;
      height: 50px;
      background: rgba(255, 255, 255, 0.06);
      border-radius: 50%;
    }
  }
  
  // 云朵3
  .cloud-3 {
    position: absolute;
    top: 32%;
    left: -160px;
    width: 110px;
    height: 38px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 19px;
    animation: cloudMove 25s linear infinite;
    z-index: 1;
    
    &::before {
      content: '';
      position: absolute;
      top: -15px;
      left: 18px;
      width: 35px;
      height: 35px;
      background: rgba(255, 255, 255, 0.05);
      border-radius: 50%;
    }
    
    &::after {
      content: '';
      position: absolute;
      top: -10px;
      right: 12px;
      width: 30px;
      height: 30px;
      background: rgba(255, 255, 255, 0.05);
      border-radius: 50%;
    }
  }
  
  // 云朵4
  .cloud-4 {
    position: absolute;
    top: 45%;
    left: -200px;
    width: 130px;
    height: 42px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 21px;
    animation: cloudMove 28s linear infinite;
    z-index: 1;
    
    &::before {
      content: '';
      position: absolute;
      top: -16px;
      left: 22px;
      width: 38px;
      height: 38px;
      background: rgba(255, 255, 255, 0.04);
      border-radius: 50%;
    }
    
    &::after {
      content: '';
      position: absolute;
      top: -12px;
      right: 18px;
      width: 32px;
      height: 32px;
      background: rgba(255, 255, 255, 0.04);
      border-radius: 50%;
    }
  }
  
  // 云朵5
  .cloud-5 {
    position: absolute;
    top: 55%;
    left: -170px;
    width: 95px;
    height: 32px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    animation: cloudMove 30s linear infinite;
    z-index: 1;
    
    &::before {
      content: '';
      position: absolute;
      top: -12px;
      left: 15px;
      width: 28px;
      height: 28px;
      background: rgba(255, 255, 255, 0.03);
      border-radius: 50%;
    }
    
    &::after {
      content: '';
      position: absolute;
      top: -8px;
      right: 10px;
      width: 24px;
      height: 24px;
      background: rgba(255, 255, 255, 0.03);
      border-radius: 50%;
    }
  }
}

@keyframes bgMove {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}

// 天气背景动画关键帧
@keyframes weatherBg {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    opacity: 0.8;
  }
  25% {
    transform: scale(1.1) rotate(1deg);
    opacity: 1;
  }
  50% {
    transform: scale(0.9) rotate(-1deg);
    opacity: 0.6;
  }
  75% {
    transform: scale(1.05) rotate(0.5deg);
    opacity: 0.9;
  }
}

// 云朵移动动画
@keyframes cloudMove {
  0% {
    left: -250px;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    left: 100%;
    opacity: 0;
  }
}

/* 页面切换淡入淡出动画 */
.fade-view-enter-active, .fade-view-leave-active {
  transition: opacity 0.6s cubic-bezier(0.4,0,0.2,1);
}
.fade-view-enter-from, .fade-view-leave-to {
  opacity: 0;
}

/* Header 入场动画 */
.header-animate {
  animation: headerIn 1s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  z-index: 2;
}
@keyframes headerIn {
  0% {
    opacity: 0;
    transform: translateY(-40px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
</style>